﻿/**
 * 判断数组是否相等
 * 1.判断数组长度相等
 * 2.判断两个数组相应位置的元素全部相等
 */
public class ArrayHelper {

    //用于判断数组是否相等
    public static boolean equal(int [] first, int [] second){
        boolean result = true;
        if (first.length == second.length){
            for (int i = 0;i <= first.length - 1;i++){
                if (first[i] != second[i]){
                    return false;
                }
            }
        } else
            return false;

        return true;
    }

    public static void main(String[] args) {
        ArrayHelper a = new ArrayHelper();

        int [] first = {2,5,8,6,9};
        int [] second = {2,5,8,6,9};
        boolean result = a.equal(first , second);
        System.out.println("这两组数组" + (result ? "相等" : "不相等"));
    }

}
